<!DOCTYPE html>
<html>
  <head>
    <title>crm修改合同</title>
    <#include "/inc/base-style.ftl">
    <link rel="stylesheet" href="${staticPath}/plugins/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css">
    <style>
        .form-group{padding-left:15px;}
    </style>
  </head>
  <body class="${bodyClass}">
    <div class="wrapper">
      <!-- Main Header -->
     <#include "/inc/main-header.ftl">
      <!-- Left side column. contains the logo and sidebar -->
      <aside class="main-sidebar">

        <!-- sidebar: style can be found in sidebar.less -->
        <section class="sidebar">
          <#include "/inc/slidebar-menu.ftl">
        </section>
        <!-- /.sidebar -->
      </aside>

      <!-- Content Wrapper. Contains page content -->
      <div class="content-wrapper">
        
        <!-- Main content -->
        <section class="content">
        <div class="box">
        
            <div class="panel panel-info">
              <div class="panel-heading">
                <h3 class="panel-title">crm修改合同</h3>
              </div>
              <div class="panel-body">
              <#if (contract.contractNo)??>
                    <form class="form-horizontal" id="modify_contract_form" action="/crm/potential/modifyContractSave" method="post">
                        <div class="form-group">
                        <label for="enterprice_is_ture">合同编号:</label>
                        <input type="text" disabled value="${contract.contractNo}">
                      </div>
                      <div class="control-group">
                        <h3 id="renewAuditLabel">系统自动设定的服务期限</h3>
                    </div>
                    <div class="control-group">
                        <label class="span3"> 开始时间: ${contract.autoBeginTime?string("yyyy-MM-dd")}</label> <label class="span9"> 结束时间: ${contract.autoEndTime?string("yyyy-MM-dd")}</label>
                    </div>
                    <div class="control-group">
                        <h3 id="renewAuditLabel">手动修改服务期限</h3>
                    </div>
                    <div class="control-group">
                        <input type="checkbox" checked name="isHande" value="1">手动修改
                    </div>
                    <div class="control-group">
                        <label class="control-label">开始时间:</label> <input type="text" value="${contract.handBeginTime?string("yyyy-MM-dd")}" name="handBeginTime" id="handBeginTime" class="my_timepicker"> 
                        <label class="control-label"> 结束时间: 开始时间顺延一年 
                        </label>
                    </div>
                    <div class="control-group">
                        <input type="hidden" name="uid" value="${contract.uid}" />
                        <input type="hidden" name="times" value="${contract.times}" / >
                        <a href="javascript:;" class="btn btn-primary active" id="modify_contract_save" role="button">保存</a>
                    </div>
                    </form>
              <#else>
                    暂无合同
              </#if>
              </div>
            </div>
            
        </div>
        
        <!-- Your Page Content Here -->

        </section><!-- /.content -->
      </div><!-- /.content-wrapper -->
    <#include "/inc/main-footer.ftl">

    

    <#include "/inc/base-script.ftl"> 
    <script src="${staticPath}/tools/js/moment/moment-with-locales.min.js"></script>
    <script src="${staticPath}/plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
    <script>
        $(function(){
        
            // 时间选择器
            $('.my_timepicker').datetimepicker({
                dayViewHeaderFormat: 'YYYY MMMM',
                locale: 'zh-cn',
                format: 'YYYY-MM-DD HH:mm:ss',
                keepInvalid: true
            });  
            
            if($('#handBeginTime').length>0) {
                $('#handBeginTime').data('DateTimePicker').useCurrent(false);
            }
            
            $("#modify_contract_save").click(function(){
                var handBeginTime = $("#handBeginTime").val().trim();
                if(handBeginTime == "") {
                    greeting({msg:"<h4 style=\"color:red\">有错误，开始时间不能为空！</h4>",title:"操作失败"});
                    return false;
                }
               
                cAjax({
                            url:  "/crm/potential/modifyContractSave",
                            data: $("#modify_contract_form").serialize(),
                            success: function(data){
                                        if(data.result) {                                             
                                            greeting({msg:"操作成功！", confirm:function(){
                                                location.reload();
                                            }});                                
                                        } else {
                                            greeting({msg:"<h4 style=\"color:red\">失败，有错误！</h4>",title:"操作失败"});
                                        }
                             },
                            error: function(obj) {
                            }
                }); 
                
            });
            
        });
    </script>
  </body>
</html>
